﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Automobile.service.Model;
using Automobile.service.BLL;
using System.Data;

namespace Automobile.service.UI
{
    public partial class WareHose_Edit : System.Web.UI.Page
    {
        WareHoseBLL bll = new WareHoseBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Txtboxbinding();
            }
        }
        protected void Txtboxbinding()
        {
            int id = Convert.ToInt32(Request.QueryString["wid"]);
            DataTable table = bll.GetWareHoseByid(id);
            this.HiddenField1.Value = id.ToString();
            WareHose_Name.Value = table.Rows[0]["WareHose_Name"].ToString();
            WareHose_People.Value = table.Rows[0]["WareHose_People"].ToString();
            WareHose_Phone.Value = table.Rows[0]["WareHose_Phone"].ToString();
            WareHose_Address.Value = table.Rows[0]["WareHose_Address"].ToString();
            WareHose_Remark.Value = table.Rows[0]["WareHose_Remark"].ToString();
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            WareHose wh = new WareHose();
            wh.WareHose_Id = int.Parse(HiddenField1.Value);
            wh.WareHose_Name = WareHose_Name.Value;
            wh.WareHose_People = WareHose_People.Value;
            wh.WareHose_Phone = WareHose_Phone.Value;
            wh.WareHose_Address = WareHose_Address.Value;
            wh.WareHose_Remark = WareHose_Remark.Value;
            if (bll.UpdWareHose(wh) > 0)
            {
                JournalBLL jbll = new JournalBLL();
                jbll.AddJourna_UpdWareHose(Convert.ToInt32(Session["empid"]),wh);
                Response.Write("<script>alert('修改成功！');parent.location.reload();parent.layer.close(parent.layer.getFrameIndex(window.name));</script>");
            }
            else
            {
                Response.Write("<script>alert('修改失败！');parent.layer.close(parent.layer.getFrameIndex(window.name));</script>");
            }
        }
    }
}